package c06.atomic;

public class AccountUnsafeTest {
    public static void main(String[] args) {
        Account account = new AccountUnsafe(10000);
        Account.transfer(account);
    }
}

class AccountUnsafe implements Account {

    private Integer balance;

    public AccountUnsafe(Integer balance) {
        this.balance = balance;
    }

    @Override
    public Integer getBalance() {
        synchronized (this) {
            return this.balance;
        }
    }

    @Override
    public void withdrawal(Integer amount) {
        synchronized (this) {
            this.balance -= amount;
        }
    }
}
